package com.itlzh.mall.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;



public class AutoFieldFillHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        strictInsertFill(metaObject,  "createTime", LocalDateTime.class, LocalDateTime.now());
        strictInsertFill(metaObject,"updateTime",  LocalDateTime.class, LocalDateTime.now());
        strictInsertFill(metaObject, "deleted",Integer.class,0);
        strictInsertFill(metaObject,"status",Integer.class,0);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
    }
}
